Skip to contentSkip to conversation

net/bnxt: add cast to wider type before multiplication

PATCH In review Denis Lyulin 2 participants 4 messages Apr 17 – Jul 29 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/bnxt: add cast to wider type before multiplication

Some static analyzers generate warnings about possible integer overflow on multiplication. The first parameter of rte_eal_alarm_set() is uint64_t, so this commit adds cast of uint32_t values before the multiplication to prevent overflow. The fix is cosmetic.

Fixes 9d0cbaecc91a ("net/bnxt: support periodic FW health monitoring")
---
 drivers/net/bnxt/bnxt_ethdev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +4 -4
index b677f9491d..bdfab3eef2 100644
@@ -4861,7 +4861,7 @@ static void bnxt_dev_recover(void *arg)
 void bnxt_dev_reset_and_resume(void *arg)
 {
 	struct bnxt *bp = arg;
-	uint32_t us = US_PER_MS * bp->fw_reset_min_msecs;
+	uint64_t us = US_PER_MS * (uint64_t)bp->fw_reset_min_msecs;
 	uint16_t val = 0;
 	int rc;
 
@@ -5008,7 +5008,7 @@ static void bnxt_check_fw_health(void *arg)
 
 	info->last_reset_counter = val;
 
-	rte_eal_alarm_set(US_PER_MS * info->driver_polling_freq,
+	rte_eal_alarm_set(US_PER_MS * (uint64_t)info->driver_polling_freq,
 			  bnxt_check_fw_health, (void *)bp);
 
 	return;
@@ -5030,7 +5030,7 @@ static void bnxt_check_fw_health(void *arg)
 	else
 		wait_msec = info->normal_func_wait_period;
 
-	rte_eal_alarm_set(US_PER_MS * wait_msec,
+	rte_eal_alarm_set(US_PER_MS * (uint64_t)wait_msec,
 			  bnxt_fw_reset_cb, (void *)bp);
 }
 
@@ -5048,7 +5048,7 @@ void bnxt_schedule_fw_health_check(struct bnxt *bp)
 
 	polling_freq = bp->recovery_info->driver_polling_freq;
 
-	rte_eal_alarm_set(US_PER_MS * polling_freq,
+	rte_eal_alarm_set(US_PER_MS * (uint64_t)polling_freq,
 			  bnxt_check_fw_health, (void *)bp);
 	bp->flags |= BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED;
 
Signature · 1 line
2.34.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Denis Lyulin

Some static analyzers generate warnings about possible integer overflow on multiplication. The first parameter of rte_eal_alarm_set() is uint64_t, so this commit adds cast of uint32_t values before the multiplication to prevent overflow. The fix is cosmetic.

Quoted 6 lines
Fixes 9d0cbaecc91a ("net/bnxt: support periodic FW health monitoring")
Quoted 49 lines
---
 drivers/net/bnxt/bnxt_ethdev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +4 -5
index b677f9491d..bdfab3eef2 100644
@@ -4861,7 +4861,7 @@ static void bnxt_dev_recover(void *arg)
 void bnxt_dev_reset_and_resume(void *arg)
 {
        struct bnxt *bp = arg;
-       uint32_t us = US_PER_MS * bp->fw_reset_min_msecs;
+       uint64_t us = US_PER_MS * (uint64_t)bp->fw_reset_min_msecs;
        uint16_t val = 0;
        int rc;
 
@@ -5008,7 +5008,7 @@ static void bnxt_check_fw_health(void *arg)
 
        info->last_reset_counter = val;
 
-       rte_eal_alarm_set(US_PER_MS * info->driver_polling_freq,
+       rte_eal_alarm_set(US_PER_MS * (uint64_t)info->driver_polling_freq,
                          bnxt_check_fw_health, (void *)bp);
 
        return;
@@ -5030,7 +5030,7 @@ static void bnxt_check_fw_health(void *arg)
        else
                wait_msec = info->normal_func_wait_period;
 
-       rte_eal_alarm_set(US_PER_MS * wait_msec,
+       rte_eal_alarm_set(US_PER_MS * (uint64_t)wait_msec,
                          bnxt_fw_reset_cb, (void *)bp);
 }
 
@@ -5048,7 +5048,7 @@ void bnxt_schedule_fw_health_check(struct bnxt *bp)
 
        polling_freq = bp->recovery_info->driver_polling_freq;
 
-       rte_eal_alarm_set(US_PER_MS * polling_freq,
+       rte_eal_alarm_set(US_PER_MS * (uint64_t)polling_freq,
                          bnxt_check_fw_health, (void *)bp);
        bp->flags |= BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED;
 
--

2.34.1

#2 lore raw

Kindly reminder
Sorry, But nobody has reviewed my small cosmetic patch on Patchwork https://patches.dpdk.org/project/dpdk/patch/[email protected]/
Could you please review this?

Quoted 70 lines · Denis Lyulin
Quoted 7 lines

Some static analyzers generate warnings about possible integer overflow on multiplication. The first parameter of rte_eal_alarm_set() is uint64_t, so this commit adds cast of uint32_t values before the multiplication to prevent overflow. The fix is cosmetic.

Quoted 5 lines
Fixes 9d0cbaecc91a ("net/bnxt: support periodic FW health monitoring")
Quoted 49 lines

---
drivers/net/bnxt/bnxt_ethdev.c | 8 ++++----

1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +2 -2
index b677f9491d..bdfab3eef2 100644
@@ -4861,7 +4861,7 @@ static void bnxt_dev_recover(void *arg)
 void bnxt_dev_reset_and_resume(void *arg)
 {
 struct bnxt *bp = arg;
-       uint32_t us = US_PER_MS * bp->fw_reset_min_msecs;
+       uint64_t us = US_PER_MS * (uint64_t)bp->fw_reset_min_msecs;
 uint16_t val = 0;
 int rc;
 
@@ -5008,7 +5008,7 @@ static void bnxt_check_fw_health(void *arg)
 
 info->last_reset_counter = val;
 
-       rte_eal_alarm_set(US_PER_MS * info->driver_polling_freq,
+       rte_eal_alarm_set(US_PER_MS * (uint64_t)info->driver_polling_freq,
 
 bnxt_check_fw_health, (void *)bp);
 

return;

drivers/net/bnxt/bnxt_ethdev.c +0 -0
@@ -5030,7 +5030,7 @@ static void bnxt_check_fw_health(void *arg)

else
wait_msec = info->normal_func_wait_period;

-       rte_eal_alarm_set(US_PER_MS * wait_msec, +       rte_eal_alarm_set(US_PER_MS * (uint64_t)wait_msec, bnxt_fw_reset_cb, (void *)bp);
}

drivers/net/bnxt/bnxt_ethdev.c +1 -2
@@ -5048,7 +5048,7 @@ void bnxt_schedule_fw_health_check(struct bnxt *bp)
 
 polling_freq = bp->recovery_info->driver_polling_freq;
 
-       rte_eal_alarm_set(US_PER_MS * polling_freq,
+       rte_eal_alarm_set(US_PER_MS * (uint64_t)polling_freq,
 bnxt_check_fw_health, (void *)bp);
 bp->flags |= BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED;
 
--

2.34.1

#3 lore raw

Hi Denis,

Accepted the change, should be merged in next cycle.

Thanks,

Kishore

*From:* Денис Люлин <[email protected]>
*Sent:* Thursday, July 23, 2026 5:36 AM
*To:* Kishore Padmanabha <[email protected]> *Cc:* Ajit Khaparde <[email protected]>; Kalesh AP < [email protected]>; [email protected]; [email protected] *Subject:* Re: [PATCH] net/bnxt: add cast to wider type before multiplication

Kindly reminder
Sorry, But nobody has reviewed my small cosmetic patch on Patchwork
https://patches.dpdk.org/project/dpdk/patch/[email protected]/
Could you please review this?

On Fri, Apr 17, 2026 at 1:23 AM Denis Lyulin <[email protected]> wrote:

Some static analyzers generate warnings about possible integer overflow on multiplication. The first parameter of rte_eal_alarm_set() is uint64_t, so this commit adds cast of uint32_t values before the multiplication to prevent overflow. The fix is cosmetic.

Fixes 9d0cbaecc91a ("net/bnxt: support periodic FW health monitoring")
---
 drivers/net/bnxt/bnxt_ethdev.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/bnxt/bnxt_ethdev.c +4 -4
index b677f9491d..bdfab3eef2 100644
@@ -4861,7 +4861,7 @@ static void bnxt_dev_recover(void *arg)
 void bnxt_dev_reset_and_resume(void *arg)
 {
        struct bnxt *bp = arg;
-       uint32_t us = US_PER_MS * bp->fw_reset_min_msecs;
+       uint64_t us = US_PER_MS * (uint64_t)bp->fw_reset_min_msecs;
        uint16_t val = 0;
        int rc;
 
@@ -5008,7 +5008,7 @@ static void bnxt_check_fw_health(void *arg)
 
        info->last_reset_counter = val;
 
-       rte_eal_alarm_set(US_PER_MS * info->driver_polling_freq,
+       rte_eal_alarm_set(US_PER_MS * (uint64_t)info->driver_polling_freq,
                          bnxt_check_fw_health, (void *)bp);
 
        return;
@@ -5030,7 +5030,7 @@ static void bnxt_check_fw_health(void *arg)
        else
                wait_msec = info->normal_func_wait_period;
 
-       rte_eal_alarm_set(US_PER_MS * wait_msec,
+       rte_eal_alarm_set(US_PER_MS * (uint64_t)wait_msec,
                          bnxt_fw_reset_cb, (void *)bp);
 }
 
@@ -5048,7 +5048,7 @@ void bnxt_schedule_fw_health_check(struct bnxt *bp)
 
        polling_freq = bp->recovery_info->driver_polling_freq;
 
-       rte_eal_alarm_set(US_PER_MS * polling_freq,
+       rte_eal_alarm_set(US_PER_MS * (uint64_t)polling_freq,
                          bnxt_check_fw_health, (void *)bp);
        bp->flags |= BNXT_FLAG_FW_HEALTH_CHECK_SCHEDULED;
 

--
2.34.1